Repository navigation
Keep error checks on when DefaultODEAlgorithm starts a mass-matrix problem stiff - #4993
Conversation
…problem stiff `default_autoswitch` starts a mass-matrix problem on the stiff branch and never switches it, but left `is_stiffalg = false`. The stiffness test still runs every step, and once it reports stiffness (large Jacobian norm, as in a stiff algebraic constraint) it sets `do_error_check = false`, because the switcher believes it is on the nonstiff branch. `solve!` then skips `check_error!` for those steps, so `maxiters`, `dtmin`, NaN `dt` and `unstable_check` stop applying: `solve(prob, DefaultODEAlgorithm(); maxiters = 3)` ran to the end with `Success`. Set `is_stiffalg` when the first choice is the stiff branch, as `stiffalgfirst = true` already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR: #4993 Reviewed head: 3b90ab4 Risk assessment
Review reportVERDICT: MERGE Riskmedium-low (ML1: restores documented failure checks on the mass-matrix branch; solver selection and tested uncapped trajectories are unchanged). Blocking findingsNone confirmed.
Non-blocking findings
What I ranReviewer: codex-cli 0.164.0, model gpt-6.1-sol. All test processes finished. The original checkout is clean.
What I did not verifyQA, GPU, supported Julia versions other than 1.13.2, downstream/full-monorepo suites, or CI. No checked-in Julia manifest pins dependencies. The baseline comparison isolates the changed method rather than running a separate full master checkout. Initial scratch probes rejected obsolete verbosity syntax and an inconsistent floating-point initial condition; both setup errors were corrected before the passing runs. No PR body, discussion, author risk rating or earlier review was read. AUTHOR_GRADE: {"task":"bugfix","score":4,"difficulty":3,"rounds":1,"author_harness":"unknown","author_model":"unknown","note":"The new regression fails four assertions with the base method and passes on the head. Core and targeted numerical/error-gate probes pass; 21 uncapped trajectories match exactly. Retrospective comments remain a minor instruction violation. The newest commit has no Agent-Harness or Agent-Model trailers."} Head link: 3b90ab4 🤖 Posted by an AI agent — harness: codex-cli 0.164.0 · model: gpt-6.1-sol |
Problem
On a mass-matrix problem,
DefaultODEAlgorithmcan turn off the integrator's error checks for the whole solve.maxiters,dtmin, NaNdtandunstable_checkthen never fire:With
k = 1.0, all three returnMaxIters.Cause
In
default_autoswitch:stiffchoice, and the mass-matrix branch never switches it. ButAS.is_stiffalgstaysfalse.is_stiffstill runs every step. Once the stiff member's Jacobian norm (eigen_est = opnorm(J, Inf)) makeseigen_est * dt / STABILITY_SIZES[...]exceed the nonstiff tolerance, it reports "stiff" and setsdo_error_check = (... || !bool) || is_stiffalg, which isfalse.solve!only callscheck_error!whendo_error_checkis set, so every check is skipped from then on.stiffalgfirst = true(and thereforeDefaultImplicitODEAlgorithm) is not affected, because it starts withis_stiffalg = true.Change
Set
AS.is_stiffalgwhenever the first choice is the stiff branch (stiffalgfirstor a non-identity mass matrix), so a mass-matrix problem is treated exactly likestiffalgfirst = true.is_stiffcompares againststifftolinstead ofnonstifftol. On the mass-matrix branch that only affects the switch counter, which this branch never acts on.reinit!: it resetsis_stiffalg = stiffalgfirstandcurrent = 0, so the first choice sets the flag again.Tests
lib/OrdinaryDiffEqDefault/test/massmatrix_error_check.jl(Core group) covers the reproducer above fork = 1andk = 1e5:maxitersis respected byDefaultODEAlgorithm()and byDefaultODEAlgorithm(stiffalgfirst = true), including afterreinit!;On master the
k = 1e5testset fails 4 of its 9 checks; with this change all pass. The OrdinaryDiffEqDefault Core group passes locally (Julia 1.13).I found no existing issue. #4878 concerns the same
is_stifffunction (NaNeigen_estread as stiff), but a different symptom.🤖 Generated with Claude Code · model: claude-opus-5-5
Review: unreviewed
Independent review: codex gpt-6-astra · 0 findings